/**
 * 
 */
package com.swim.settlementrecord.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.swim.settlementrecord.entity.SettlementRecord;
import com.swim.settlementrecord.service.SettlementRecordService;

/**
 * 结算记录Controller
 * @author 刘军武
 * @version 2021-03-05
 */
@Controller
@RequestMapping(value = "${adminPath}/settlementrecord/settlementRecord")
public class SettlementRecordController extends BaseController {

	@Autowired
	private SettlementRecordService settlementRecordService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public SettlementRecord get(String id, boolean isNewRecord) {
		return settlementRecordService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表（游泳馆）
	 */
	@RequiresPermissions("settlementrecord:settlementRecord:view")
	@RequestMapping(value = {"natatoriumList", ""})
	public String natatoriumList(SettlementRecord settlementRecord, Model model) {
		model.addAttribute("settlementRecord", settlementRecord);
		return "swim/settlementrecord/settlementRecordNatatoriumList";
	}	
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("settlementrecord:settlementRecord:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<SettlementRecord> listData(SettlementRecord settlementRecord, HttpServletRequest request, HttpServletResponse response) {
		Page<SettlementRecord> page = settlementRecordService.findPage(new Page<SettlementRecord>(request, response), settlementRecord); 
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("settlementrecord:settlementRecord:view")
	@RequestMapping(value = "form")
	public String form(SettlementRecord settlementRecord, Model model) {
		model.addAttribute("settlementRecord", settlementRecord);
		return "swim/settlementrecord/settlementRecordForm";
	}

	/**
	 * 保存结算记录
	 */
	@RequiresPermissions("settlementrecord:settlementRecord:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated SettlementRecord settlementRecord) {
		settlementRecordService.save(settlementRecord);
		return renderResult(Global.TRUE, text("保存结算记录成功！"));
	}
	
	/**
	 * 跳转查看详情页
	 */
	@RequiresPermissions("settlementrecord:settlementRecord:view")
	@RequestMapping(value = "natatoriumDetails")
	public String natatoriumDetails(SettlementRecord settlementRecord, Model model) {
		model.addAttribute("settlementRecord", settlementRecord);
		return "swim/settlementrecord/settlementRecordNatatoriumDetails";
	}
	
	//#################################################
	//################ 平台 结算记录列表 ###################
	//#################################################
	
	/**
	 * 查询列表（平台）
	 */
//	@RequiresPermissions("settlementrecord:settlementRecord:view")
	@RequestMapping(value = {"platformList", ""})
	public String platformList(SettlementRecord settlementRecord, Model model) {
		model.addAttribute("settlementRecord", settlementRecord);
		return "swim/settlementrecord/settlementRecordNatatoriumPlatformList";
	}	
}